package com.aat.dxfy.safe;

import org.apache.tomcat.util.codec.binary.Base64;

public class AesString extends AESCoder {

	public String key;

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String jiami(String str) {
		try {
			if (str != null && key != null) {
				byte[] bsk = Base64.decodeBase64(key);
				byte[] jia = encrypt(str.getBytes(), bsk);
				return Base64.encodeBase64String(jia);
			}
		} catch (Exception e) {
		}
		return null;

	}

	public String jiemi(String str) {
		try {
			if (str != null && key != null) {
				byte[] bsk = Base64.decodeBase64(key);
				byte[] jie = Base64.decodeBase64(str);
				byte[] res = decrypt(jie, bsk);
				return new String(res);
			}
		} catch (Exception e) {
		}
		return null;
	}

}
